package com.itheima.tlias.utils;

/**
 * 用于操作当前登录人(员工)的id
 */
public class CurrentHolder {
    // 线程安全的ThreadLocal对象，用于存储当前线程的id
    private static final ThreadLocal<Integer> CURRENT_LOCAL = new ThreadLocal<>();

    // 获取当前线程的id
    public static Integer getCurrentId() {
        return CURRENT_LOCAL.get();
    }

    // 设置当前线程的id
    public static void setCurrentId(Integer employeeId) {
        CURRENT_LOCAL.set(employeeId);
    }

    // 移除当前线程的id
    public static void remove() {
        CURRENT_LOCAL.remove();
    }
}